function $(a) {
  return document.querySelector(a);
}
function previewFile(a, b) {
  var onImg = document.querySelector(a);
  var file = document.querySelector(b).files[0];
  var reader = new FileReader();
  reader.addEventListener(
    "load",
    function () {
      onImg.src = this.result;
    },
    false
  );

  if (file) {
    reader.readAsDataURL(file);
  }
}
var tbody = document.querySelector("tbody");
// 退出登录
// $('.exit').onclick=function(){
//     axios({
//         method: 'post',
//         url: '/user/logout',
//     }).then(function(data){
//        alert('退出登录')
//     }).catch(err=>{
//         console.log(err);
//     })
// }
// 预览大图片
function displayphoto(a, list) {
  var videophoto = document.querySelectorAll(a);
  for (let j = 0; j < videophoto.length; j++) {
    videophoto[j].onclick = function () {
      console.log(j);
      $(".bigphoto").src = list[j].videoPhoto;
      $(".photo-box").style.display = "block";
      // 退出照片预览
      $(".back3").onclick = function () {
        $(".photo-box").style.display = "none";
      };
    };
  }
}
// 预览演员图片
function displayactorphoto(a, list) {
  var videophoto = document.querySelectorAll(a);
  for (let j = 0; j < videophoto.length; j++) {
    videophoto[j].onclick = function () {
      console.log(j);
      $(".bigphoto").src = list[j].actorSrc;
      $(".photo-box").style.display = "block";
      // 退出照片预览
      $(".back3").onclick = function () {
        $(".photo-box").style.display = "none";
      };
    };
  }
}

// 弹窗显示
function popup(a, b, c) {
  a.addEventListener("click", function () {
    b.style.display = "block";
    $(".accomplishment").value = "";
    $(".actorBirthday").value = "";
    $(".actorIntroduction").value = "";
    $(".actorName").value = "";
    $(".actorNation").value = "";
    $(".actorNickName").value = "";
    $(".actorOccupation").value = "";
    $(".popularity").value = "";
    // $('.account').value='';
    // $('.password').value='';
    // $('.nickname').value='';
  });
  c.addEventListener("click", function () {
    b.style.display = "none";
  });
}
popup($(".add-all"), $(".add-box"), $(".back"));

//  全部数据
$(".alllist").onclick = function () {
  $(".pageSize").style.display = "block";
  $(".pageSize1").style.display = "none";
  $(".nowpage-1").innerHTML = 1;
  $(".nowpage").value = $(".nowpage-1").innerHTML;
  $("#search").value = "";
  fenye(1, $(".pageSize").value);
};

// 点击显示数据每页几条
$(".pageSize").onchange = function () {
  $(".nowpage-1").innerHTML = 1;
  $(".nowpage").value = $(".nowpage-1").innerHTML;
  fenye(1, $(".pageSize").value);
};
$(".pageSize1").onchange = function () {
  $(".nowpage-1").innerHTML = 1;
  $(".nowpage").value = $(".nowpage-1").innerHTML;
  searchdata(1, $(".pageSize1").value);
};
// 简介字数太多隐藏
function str(b) {
  let s = "";
  if (b.length >= 15) {
    for (let i = 0; i < 15; i++) {
      s += b[i];
    }
    s += "...";
  } else {
    for (let i = 0; i < b.length; i++) {
      s += b[i];
    }
  }
  return s;
}
// // 渲染数据
function fenye(a, b) {
  axios({
    method: "get",
    url: "/actor/findAllActorMsgLimitPage",
    params: {
      pageNow: a,
      pageSize: b,
    },
  })
    .then(function (data) {
      $("tbody").innerHTML = "";
      $(".pageye").innerHTML = "";
      list(data, fenye);
    })
    .catch((err) => {
      console.log(err);
    });
}
fenye(1, 10);

// 模糊查询
function searchdata(a, b) {
  var search_input = document.querySelector("#search");
  axios({
    method: "get",
    url: "/actor/findActorsByLikeActorName",
    params: {
      actorName: search_input.value,
      pageNow: a,
      pageSize: b,
    },
  })
    .then(function (data) {
      console.log(data.data.data.data.list);
      if (data.data.data.data.list.length == 0) {
        $("#search").value = "";
        $(".pageSize1").style.display = "none";
        $(".pageSize").style.display = "";
        $(".nowpage-btn-2").style.display = "none";
        $(".nowpage-btn-1").style.display = "";
        $(
          ".not"
        ).innerHTML = `<i class="fa fa-exclamation-circle" style="color: rgb(255, 187, 0);" aria-hidden="true"></i>抱歉找不到`;
        $(".not").style.display = "";
        setTimeout(() => {
          $(".not").style.display = "none";
        }, 1500);
      } else {
        $("tbody").innerHTML = "";
        $(".pageye").innerHTML = "";
        $(".pageSize1").style.display = "";
        $(".pageSize").style.display = "none";
        $(".nowpage-btn-2").style.display = "";
        $(".nowpage-btn-1").style.display = "none";
        list(data, searchdata);
      }
    })
    .catch((err) => {
      console.log(err);
    });
}
//  点击搜索按钮
$(".search-btn").addEventListener("click", function () {
  $(".nowpage-1").innerHTML = 1;
  $(".nowpage").value = $(".nowpage-1").innerHTML;
  var search_input = document.querySelector("#search");
  if (search_input.value == "") {
    $(
      ".not"
    ).innerHTML = `<i class="fa fa-exclamation-circle" style="color: rgb(255, 187, 0);" aria-hidden="true"></i>抱歉找不到`;
    $(".not").style.display = "";
    setTimeout(() => {
      $(".not").style.display = "none";
    }, 1500);
  } else {
    $(
      ".not"
    ).innerHTML = `<i class="fa fa-check" aria-hidden="true" style="color:green"></i>搜索成功`;
    $(".not").style.display = "";
    setTimeout(() => {
      $(".not").style.display = "none";
    }, 1500);
    searchdata(1, $(".pageSize").value);
  }
});
// // 分页数据
function list(data, b) {
  let list = data.data.data.data.list;
  let pageNow = data.data.data.data.pageNow;
  for (let i = 0; i < list.length; i++) {
    let tds = ` <tr>
        <td><input name="checkbox" type="checkbox" value="checkbox" class="chexkbox" /></td>
        <td>${i + 1 + (pageNow - 1) * $(".pageSize").value}</td>
        <td>${list[i].actorName == null ? "无" : list[i].actorName}</td>
        <td><img class="photo2" src="${
          list[i].actorSrc == null ? "#" : list[i].actorSrc
        }" style="width:40px;height:40px;"></img></td>
        <td>${list[i].actorNation == null ? "无" : list[i].actorNation}</td>
        <td>${list[i].popularity == null ? "无" : list[i].popularity}</td>
        <td><button class="upload-src">上传封面</button><button class="message">详情</button><button class='works-btn'><i class="fa fa-book" aria-hidden="true"></i> 作品</button><button class="modify-btn"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 修改</button><button class='delete-actor'><i class="fa fa-trash-o" aria-hidden="true"></i> 删除</button></td>
    </tr>`;
    $("tbody").insertAdjacentHTML("beforeend", tds);
    var tbr = tbody.querySelectorAll("tr");
    if (i % 2 == 0) {
      tbr[i].style.backgroundColor = "rgb(220, 220, 220)";
      tbr[i].onmouseover = function () {
        this.style.backgroundColor = "rgb(202, 170, 145)";
      };
      tbr[i].onmouseout = function () {
        this.style.backgroundColor = "rgb(220, 220, 220)";
      };
    }
  }

  displayactorphoto(".photo2", list);
  // 详情按钮
  var message_btn = document.querySelectorAll(".message");
  console.log(message_btn);
  for (let i = 0; i < message_btn.length; i++) {
    popup(message_btn[i], $(".user-box"), $(".back0"));
    message_btn[i].onclick = function () {
      var actorId = list[i].actorId;
      console.log(actorId);
      message(actorId);
    };
  }

  // 上传封面按钮
  var upload_src = document.querySelectorAll(".upload-src");
  for (let i = 0; i < upload_src.length; i++) {
    popup(upload_src[i], $(".upload-box"), $(".back-upload"));
    upload_src[i].onclick = function () {
      var actorId = list[i].actorId;
      console.log(actorId);
      $(".clear1").onclick = function () {
        $("file").value = "";
      };
      uploadSrc(actorId);
    };
  }
  // 作品按钮
  var works_btn = document.querySelectorAll(".works-btn");
  for (let i = 0; i < works_btn.length; i++) {
    popup(works_btn[i], $(".works-box"), $(".back2"));
    works_btn[i].onclick = function () {
      var actorId = list[i].actorId;
      var actorName = list[i].actorName;
      $(".works-box-all").querySelector("h3").innerHTML = actorName + "作品";
      console.log(actorName);
      console.log(actorId);
      works(actorId);
    };
  }
  // 删除按钮绑定
  var del_btn = document.querySelectorAll(".delete-actor");
  for (let i = 0; i < del_btn.length; i++) {
    del_btn[i].onclick = function () {
      var x = 2;
      if ((x = 2)) {
        console.log(x);
        $(".form-pop").querySelector("p").innerHTML = "你确定要删除吗？";
        $(".pop-box").style.display = "block";
        $(".submit-pop1").onclick = function () {
          var actorId = list[i].actorId;
          delete_actor(actorId, b);
          $(".pop-box").style.display = "none";
        };
        $(".submit-pop2").onclick = function () {
          $(".pop-box").style.display = "none";
        };
        $(".back-pop").onclick = function () {
          $(".pop-box").style.display = "none";
        };
      }
    };
  }

  //  分页的总量
  var pageTotal = data.data.data.data.pageTotal;
  var pageTotalCount = data.data.data.data.pageTotalCount;

  // 跳转按钮
  $(".nowpage").value = $(".nowpage-1").innerHTML;
  $(".nowpage-btn-1").onclick = function () {
    $(".nowpage-1").innerHTML =
      $(".nowpage").value > pageTotal ? pageTotal : $(".nowpage").value;
    fenye($(".nowpage-1").innerHTML, $(".pageSize").value);
  };
  $(".total").innerHTML = `共${pageTotal}页共${pageTotalCount}条数据`;
  if (pageTotal < 3) {
    for (let i = 0; i < pageTotal; i++) {
      let a = ` <a href="JavaScript:;" class='pagebtn'>${i + 1}</a>`;
      $(".pageye").insertAdjacentHTML("beforeend", a);
    }
  } else {
    for (let i = 0; i < 3; i++) {
      let a = ` <a href="JavaScript:;" class='pagebtn'>${i + 1}</a>`;
      $(".pageye").insertAdjacentHTML("beforeend", a);
    }
    var pagebtnAll = document.querySelectorAll(".pagebtn");
    if ($(".nowpage").value >= 3) {
      let c = $(".nowpage").value;
      let a = c >= pageTotal - 1 ? (c = pageTotal - 1) : c;
      pagebtnAll[0].innerHTML = a - 1;
      pagebtnAll[1].innerHTML = a;
      pagebtnAll[2].innerHTML = ++a;
    }
  }
  var pagebtnAll = document.querySelectorAll(".pagebtn");
  for (let i = 0; i < pagebtnAll.length; i++) {
    pagebtnAll[i].onclick = function () {
      b(this.innerHTML, $(".pageSize").value);
      $(".nowpage-1").innerHTML = `${this.innerHTML}`;
      $(".nowpage").value = $(".nowpage-1").innerHTML;
    };
    if (pagebtnAll[i].innerHTML == $(".nowpage-1").innerHTML) {
      pagebtnAll[i].style.backgroundColor = "rgb(202,170,145)";
    } else if (pagebtnAll[i].innerHTML == $(".nowpage").value) {
      for (let j = 0; j < pagebtnAll.length; j++) {
        pagebtnAll[j].style.backgroundColor = "";
      }
      pagebtnAll[i].style.backgroundColor = "rgb(202,170,145)";
    }
  }
  $("#next").onclick = function () {
    var x = $(".nowpage-1").innerHTML;
    x++;
    var y = x >= pageTotal ? (x = pageTotal) : x;
    $(".nowpage-1").innerHTML = `${y}`;
    $(".nowpage").value = $(".nowpage-1").innerHTML;
    b($(".nowpage-1").innerHTML, $(".pageSize").value);
    console.log($(".nowpage-1").innerHTML, $(".nowpage").value);
    console.log($(".nowpage").value);
  };
  $("#pre").onclick = function () {
    var x = $(".nowpage-1").innerHTML;
    x--;
    var y = x <= 1 ? (x = 1) : x;
    $(".nowpage-1").innerHTML = `${y}`;
    $(".nowpage").value = $(".nowpage-1").innerHTML;
    b($(".nowpage-1").innerHTML, $(".pageSize").value);
  };
  $(".frist").onclick = function () {
    $(".nowpage-1").innerHTML = `1`;
    $(".nowpage").value = $(".nowpage-1").innerHTML;
    b(1, $(".pageSize").value);
  };
  $(".last").onclick = function () {
    $(".nowpage-1").innerHTML = `${pageTotal}`;
    $(".nowpage").value = $(".nowpage-1").innerHTML;
    b(pageTotal, $(".pageSize").value);
  };

  // 复选框
  var checkbox = document.querySelectorAll(".chexkbox");
  $("#checkbox-all").onclick = function () {
    if ($("#checkbox-all").checked) {
      for (let i = 0; i < checkbox.length; i++) {
        checkbox[i].checked = "checked";
      }
    } else {
      for (let i = 0; i < checkbox.length; i++) {
        checkbox[i].checked = "";
      }
    }
  };
  $(".delete-all").onclick = function () {
    var x = 2;
    if ((x = 2)) {
      console.log(x);
      $(".form-pop").querySelector("p").innerHTML = "你确定要批量删除吗？";
      $(".pop-box").style.display = "block";
      $(".submit-pop1").onclick = function () {
        var Ids = [];
        for (let i = 0; i < checkbox.length; i++) {
          if (checkbox[i].checked) {
            Ids += list[i].actorId + ",";
          }
        }
        delete_actorAll(Ids, b);
        $(".pop-box").style.display = "none";
      };
      $(".submit-pop2").onclick = function () {
        $(".pop-box").style.display = "none";
      };
      $(".back-pop").onclick = function () {
        $(".pop-box").style.display = "none";
      };
    }
  };
  //  修改按钮绑定
  var modify_btn = document.querySelectorAll(".modify-btn");
  for (let i = 0; i < modify_btn.length; i++) {
    popup(modify_btn[i], $(".modify-box"), $(".back1"));
    modify_btn[i].onclick = function () {
      $(".actorName1").value = list[i].actorName;
      $(".actorNickName1").value =
        list[i].actorNickName == null || "" ? "无" : list[i].actorNickName;
      $(".actorBirthday1").value =
        list[i].actorBirthday == null ? "无" : list[i].actorBirthday;
      $(".actorOccupation1").value = list[i].actorOccupation;
      $(".actorIntroduction1").value = list[i].actorIntroduction;
      $(".popularity1").value = list[i].popularity;
      $(".accomplishment1").value = list[i].accomplishment;
      $(".actorNation1").value = list[i].actorNation;
      var actorId = list[i].actorId;
      console.log(actorId);
      updateactor(actorId);
    };
  }
}
//模糊查询数据
function searchlist(data) {
  let list = data.data.data.data;
  // let pageNow = data.data.data.data.pageNow;
  for (let i = 0; i < list.length; i++) {
    let tds = ` <tr>
        <td>${i + 1}</td>
        <td>${list[i].actorName == null ? "无" : list[i].actorName}</td>
        <td>${list[i].actorNation == null ? "无" : list[i].actorNation}</td>
        <td>${
          list[i].actorNickName == null ? "无" : str(list[i].actorNickName)
        }</td>
        <td>${list[i].popularity == null ? "无" : list[i].popularity}</td>
        <td><button class='delete-user'><i class="fa fa-trash-o" aria-hidden="true"></i> 删除</button></td>
    </tr>`;
    $("tbody").insertAdjacentHTML("beforeend", tds);
    var tbr = tbody.querySelectorAll("tr");
    if (i % 2 == 0) {
      tbr[i].style.backgroundColor = "rgb(220, 220, 220)";
      tbr[i].onmouseover = function () {
        this.style.backgroundColor = "rgb(202, 170, 145)";
      };
      tbr[i].onmouseout = function () {
        this.style.backgroundColor = "rgb(220, 220, 220)";
      };
    }
  }
  //         // 删除按钮绑定
  //         var del_btn = document.querySelectorAll('.delete-user');
  //      for(let i = 0 ;i<del_btn.length; i++){
  //      del_btn[i].addEventListener('click',function(){
  //         var userId =list[i].userId;
  //         delete_user(userId);
  //      })
  //      }

  //     //  分页的总量
  //     var pageTotal =data.data.data.data.pageTotal;
  //     var pageTotalCount=data.data.data.data.pageTotalCount;
  //     $('.total').innerHTML=`共${pageTotal}页共${pageTotalCount}条数据`;
  //     if(pageTotal<3){
  //         for(let i = 0;i<pageTotal;i++){
  //             let a=` <a href="JavaScript:;" class='pagebtn'>${i+1}</a>`;
  //             $('.pageye').insertAdjacentHTML('beforeend',a);
  //          }
  // }else{
  //     for(let i = 0;i<3;i++){
  //         let a=` <a href="JavaScript:;" class='pagebtn'>${i+1}</a>`;
  //         $('.pageye').insertAdjacentHTML('beforeend',a);
  //      }
  //      var pagebtnAll = document.querySelectorAll('.pagebtn');
  //      if( $('.nowpage').value>=3){
  //          let c=$('.nowpage').value;
  //          let a=c>=pageTotal-1?c=pageTotal-1:c;
  //             pagebtnAll[0].innerHTML=a-1;
  //             pagebtnAll[1].innerHTML=a;
  //             pagebtnAll[2].innerHTML=++a;
  //             }
  // }
  // var pagebtnAll = document.querySelectorAll('.pagebtn');
  // for(let i = 0;i<pagebtnAll.length;i++){
  //     pagebtnAll[i].onclick = function(){
  //     b(this.innerHTML,$('.pageSize').value);
  //     $('.nowpage-1').innerHTML=`${this.innerHTML}`;
  //     $('.nowpage').value=$('.nowpage-1').innerHTML;
  //     }
  //     if(pagebtnAll[i].innerHTML==$('.nowpage-1').innerHTML){
  //         pagebtnAll[i].style.backgroundColor='rgb(202,170,145)';
  //     }else if(pagebtnAll[i].innerHTML==$('.nowpage').value){
  //         for(let j = 0;j<pagebtnAll.length;j++){
  //             pagebtnAll[j].style.backgroundColor='';
  //         }
  //         pagebtnAll[i].style.backgroundColor='rgb(202,170,145)';
  //     }
  // }
  //  $('#next').onclick=function(){
  //      var x = $('.nowpage-1').innerHTML;
  //      x++;
  //      var y = x>=pageTotal?x =pageTotal:x;
  //      $('.nowpage-1').innerHTML=`${y}`;
  //      $('.nowpage').value=$('.nowpage-1').innerHTML;
  //      b( $('.nowpage-1').innerHTML,$('.pageSize').value)
  //      console.log($('.nowpage-1').innerHTML,$('.nowpage').value);
  //      console.log($('.nowpage').value);
  // }
  // $('#pre').onclick=function(){
  //     var x = $('.nowpage-1').innerHTML;
  //     x--;
  //     var y = x<=1?x =1:x;
  //     $('.nowpage-1').innerHTML=`${y}`;
  //     $('.nowpage').value=$('.nowpage-1').innerHTML;
  //     b($('.nowpage-1').innerHTML,$('.pageSize').value)
  // }
  // $('.frist').onclick=function(){
  //     $('.nowpage-1').innerHTML=`1`;
  //     $('.nowpage').value=$('.nowpage-1').innerHTML;
  //     b(1,$('.pageSize').value)
  // }
  // $('.last').onclick=function(){
  //     $('.nowpage-1').innerHTML=`${pageTotal}`;
  //     $('.nowpage').value=$('.nowpage-1').innerHTML;
  //     b(pageTotal,$('.pageSize').value)
  // }

  //     //  修改按钮绑定
  //     var modify_btn = document.querySelectorAll('.modify-btn');
  //     for(let i = 0 ;i<modify_btn.length; i++){
  //     popup(modify_btn[i],$(".modify-box"),$(".back1"));
  //      modify_btn[i].onclick=function(){
  //         $(".age1").value =list[i].age==null?'':list[i].age;
  //         $(".birthday1").value =list[i].birthday==null?'无':list[i].birthday;
  //         $(".email1").value =list[i].email
  //         $(".nickname1").value =list[i].nickname==null?'无':list[i].nickname;
  //         $(".password1").value =list[i].password;
  //         $(".sex1").value =list[i].sex==null?'无':list[i].sex;
  //         var account =list[i].account;
  //         updatauser(account);
  //      }
  //      }
}

// 添加演员
$(".submit").onclick = function () {
  let data = [
    {
      accomplishment: $(".accomplishment").value,
      actorBirthday: $(".actorBirthday").value,
      actorIntroduction: $(".actorIntroduction").value,
      actorName: $(".actorName").value,
      actorNation: $(".actorNation").value,
      actorNickName: $(".actorNickName").value,
      actorOccupation: $(".actorOccupation").value,
      popularity: $(".popularity").value,
    },
  ];
  axios
    .put("/actor/addMoreActorMsgForVideo", data)
    .then(function (data) {
      console.log(1);
      var object = data.data.data.message;
      console.log(object);
      if (object === "成功") {
        $(
          ".not"
        ).innerHTML = `<i class="fa fa-check-circle" style="color:green;" aria-hidden="true"></i></i>添加成功`;
        $(".not").style.display = "";
        setTimeout(() => {
          $(".not").style.display = "none";
        }, 2000);
        $(".add-box").style.display = "none";
        fenye($(".nowpage-1").innerHTML, $(".pageSize").value);
      } else {
        alert("添加失败");
        $(".add-box").style.display = "none";
      }
    })
    .catch((err) => {
      console.log(123123123123);
      console.log(err);
    });
};
// 遍历演员作品信息
function works(actorId) {
  $(".listbody").innerHTML = "";
  axios({
    method: "get",
    url: "/actor/findActorMessage",
    params: {
      actorId: actorId,
    },
  })
    .then(function (data) {
      console.log(data.data.data.data.全部[0].videoList);
      listworks(data);
    })
    .catch((err) => {
      console.log(err);
    });
}
// 查询演员信息
function message(actorId) {
  axios({
    method: "get",
    url: "/actor/findActorMessage",
    params: {
      actorId: actorId,
    },
  })
    .then(function (data) {
      function text(b, a, c, d, e) {
        if (a.length > 15) {
          $(b).innerHTML = `${str(a)} <button class="spread${d}">展开</button>`;
          $(e).onclick = function () {
            $(".h3").innerHTML = c;
            $(".user-box").style.display = "none";
            $(".introduction-box").style.display = "block";
            $(".form-introduction").innerHTML = a;
            $(".back-introduction").onclick = function () {
              $(".user-box").style.display = "block";
              $(".introduction-box").style.display = "none";
            };
          };
        } else {
          $(b).innerHTML = `${str(a)} `;
        }
      }
      let list = data.data.data.data.全部[0];
      $(".actor-Name").innerHTML = list.actorName;
      $(".actor-Birthday").innerHTML = list.actorBirthday;
      $(".actor-Nation").innerHTML = list.actorNation;
      text(".actor-NickName", list.actorNickName, "主演名字", 1, ".spread1");
      text(".actor-Occupation", list.actorOccupation, "荣誉", 2, ".spread2");
      // $('.actor-NickName').innerHTML=str(list.actorNickName)
      // $('.actor-Occupation').innerHTML=str(list.actorOccupation)
      $(".actor-popular").innerHTML = list.popularity;
      text(
        ".actor-Introduction",
        list.actorIntroduction,
        "演员介绍",
        3,
        ".spread3"
      );
      text(
        ".actor-accomplishment",
        list.accomplishment,
        "演员历史",
        4,
        ".spread4"
      );
      // $('.actor-Introduction').innerHTML=str(list.actorIntroduction)
      // $('.actor-accomplishment').innerHTML=str(list.accomplishment)
    })
    .catch((err) => {
      console.log(err);
    });
}
// 演员作品信息数据
function listworks(data) {
  let list = data.data.data.data.全部[0].videoList;
  for (let i = 0; i < list.length; i++) {
    let tds = ` <tr>
        <td><input name="checkbox" type="checkbox" value="checkbox" class="chexkbox1" /></td>
        <td>${i + 1}</td>
        <td>${list[i].videoName == null ? "无" : list[i].videoName}</td>
        <td><img class="photo1" src="${
          list[i].videoPhoto == null ? "#" : list[i].videoPhoto
        }" style="width:40px;height:40px;"></img></td>
        <td>${
          list[i].videoYear == null ? "无" : list[i].videoYear.replace("_", "")
        }</td>
        <td>${list[i].videoType == null ? "无" : list[i].videoType}</td>
    </tr>`;
    $(".listbody").insertAdjacentHTML("beforeend", tds);
    let tbr = $(".listbody").querySelectorAll("tr");
    if (i % 2 == 0) {
      tbr[i].style.backgroundColor = "rgb(220, 220, 220)";
      tbr[i].onmouseover = function () {
        this.style.backgroundColor = "rgb(202, 170, 145)";
      };
      tbr[i].onmouseout = function () {
        this.style.backgroundColor = "rgb(220, 220, 220)";
      };
    }
  }
  // 预览图片
  displayphoto(".photo1", list);
  // // 删除按钮
  // let delete_commentSonbtn = document.querySelectorAll('.delete-commentSon')
  // for(let i = 0 ; i<delete_commentSonbtn.length;i++){
  //     delete_commentSonbtn[i].onclick=function(){
  //         let commentSonId=list[i].commentSonId
  //         console.log(commentSonId);
  //         delete_commentSon(commentSonId);
  //     }
  // }
  // // 复选框
  // var checkbox1 = document.querySelectorAll('.chexkbox1');
  //     $('#checkbox-all1').onclick=function(){
  //        if($('#checkbox-all1').checked){
  //         for(let i = 0 ;i< checkbox1.length; i++){
  //             checkbox1[i].checked = 'checked';
  //        }
  //        }else{
  //         for(let i = 0 ;i< checkbox1.length; i++){
  //             checkbox1[i].checked = '';
  //        }
  //        }
  // }
  // $('.delete-commentSonAll').onclick=function(){
  //     if(confirm('你是否要批量删除')){
  //     for(let i = 0 ;i< checkbox1.length; i++){
  //         if(checkbox1[i].checked){
  //             let commentSonId=list[i].commentSonId;
  //             console.log(commentSonId);
  //             delete_AllcommentSon(commentSonId);
  //         }
  // }
  // $('.not1').innerHTML=`<i class="fa fa-times-circle-o" aria-hidden="true"  style="color:red;"></i>删除成功`
  //         $('.not1').style.display=''
  //         setTimeout(() => {
  //            $('.not1').style.display='none'
  //        }, 2000);
  // commentSon(list[0].commentId)
  // }
  // }
}
// 删除单个演员
function delete_actor(actorId, b) {
  axios({
    method: "delete",
    url: "/actor/deleteActorByActorId",
    params: {
      actorId: actorId,
    },
  })
    .then(function (data) {
      $(
        ".not"
      ).innerHTML = `<i class="fa fa-check" aria-hidden="true" style="color:green"></i>删除成功`;
      $(".not").style.display = "";
      setTimeout(() => {
        $(".not").style.display = "none";
      }, 1500);
      b($(".nowpage-1").innerHTML, $(".pageSize").value);
    })
    .catch((err) => {
      console.log(err);
    });
}
// 批量删除演员
function delete_actorAll(Ids, b) {
  axios({
    method: "delete",
    url: "/actor/deleteActorsByActorIds",
    params: {
      Ids: Ids,
    },
  })
    .then(function (data) {
      $(
        ".not"
      ).innerHTML = `<i class="fa fa-check" aria-hidden="true" style="color:green"></i>删除成功`;
      $(".not").style.display = "";
      setTimeout(() => {
        $(".not").style.display = "none";
      }, 1500);
      b($(".nowpage-1").innerHTML, $(".pageSize").value);
    })
    .catch((err) => {
      console.log(err);
    });
}
// 修改演员
function updateactor(actorId) {
  $(".submit1").onclick = function () {
    axios({
      method: "put",
      url: "/actor/updateActorMessageByActorId",
      params: {
        accomplishment: $(".accomplishment1").value,
        actorBirthday: $(".actorBirthday1").value,
        actorIntroduction: $(".actorIntroduction1").value,
        actorName: $(".actorName1").value,
        actorNation: $(".actorNation1").value,
        actorNickName: $(".actorNickName1").value,
        actorOccupation: $(".actorOccupation1").value,
        popularity: $(".popularity1").value,
        actorId: actorId,
      },
    })
      .then(function (data) {
        console.log(data.data);
        let data1 = data.data.data;
        if (data1.message == "成功") {
          $(
            ".not"
          ).innerHTML = `<i class="fa fa-check-circle" style="color:green;" aria-hidden="true"></i></i>修改成功`;
          $(".not").style.display = "";
          setTimeout(() => {
            $(".not").style.display = "none";
          }, 2000);
          $(".modify-box").style.display = "none";
          fenye($(".nowpage-1").innerHTML, $(".pageSize").value);
        } else {
          alert(data1.message);
        }
      })
      .catch((err) => {
        console.log(err);
      });
  };
}

function uploadSrc(actorId) {
  $(".submit-upload").onclick = function () {
    var file = $(".file").files[0];
    const formdata = new FormData();
    formdata.append("File", file);
    axios({
      url: "/actor/updateActorSculpture",
      data: formdata,
      params: {
        actorId: actorId,
      },
      method: "put",
    })
      .then((data) => {
        $(".not").style.display = "none";
        console.log(10085);
        console.log("addAdvertisement  : ", data.data);
        if (data.data.message == "成功") {
          $(
            ".not"
          ).innerHTML = `<i class="fa fa-check" aria-hidden="true" style="color:green"></i> 添加成功`;
          $(".not").style.display = "";
          setTimeout(() => {
            $(".not").style.display = "none";
          }, 1500);
          $(".add-box").style.display = "none";
          fenye($(".nowpage-1").innerHTML, $(".pageSize").value);
        } else {
          $(
            ".not"
          ).innerHTML = `<i class="fa fa-times" aria-hidden="true" style="color:red;"></i> 添加失败`;
          $(".not").style.display = "";
          setTimeout(() => {
            $(".not").style.display = "none";
          }, 1500);
          $(".add-box").style.display = "none";
        }
      })
      .catch((err) => {
        console.log("addAdvertisement err : ", err);
      });
  };
}
